<template>
  <div>
    <div align="center">
      <label size="large" label-width="280px">— — — — — — — — — — — </label><br/>
      <label size="large" label-width="280px">* * * 供水管道爆管定位模型 * * *</label><br/>
      <label size="large" label-width="280px">— — — — — — — — — — — </label>
    </div>
    <el-form ref="elForm" :model="formData" :rules="rules" size="medium" label-width="300px">
      <el-form-item label="编号" prop="number">
        <el-input v-model="formData.number" placeholder="请输入编号" show-word-limit clearable
                  :style="{width: '80%'}"></el-input>
      </el-form-item>
      <el-form-item label="压力计和流量计的上下游关系" prop="sxygx">
        <el-select v-model="formData.sxygx" placeholder="请选择压力计和流量计的上下游关系" clearable :style="{width: '80%'}">
          <el-option v-for="(item, index) in sxygxOptions" :key="index" :label="item.label"
                     :value="item.value" :disabled="item.disabled"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="监测点流量（m^3/s）" prop="jcdll">
        <el-input v-model="formData.jcdll" placeholder="请输入监测点流量（m^3/s）" clearable :style="{width: '80%'}">
        </el-input>
      </el-form-item>
      <el-form-item label="周边流量（m^3/s）" prop="zbll">
        <el-input v-model="formData.zbll" placeholder="请输入周边流量（m^3/s）" clearable :style="{width: '80%'}">
        </el-input>
      </el-form-item>
      <el-form-item size="large">
        <el-button type="primary" @click="submitForm">提交</el-button>
        <el-button @click="resetForm">重置</el-button>
      </el-form-item>
    </el-form>
    <el-dialog
      title="评估结果"
      :visible.sync="centerDialogVisible"
      width="30%"
      center>
      <span>编号:{{number}};评估结果:{{name}}</span>
      <span slot="footer" class="dialog-footer">
    <el-button @click="centerDialogVisible = false">取 消</el-button>
    <el-button type="primary" @click="centerDialogVisible = false">确 定</el-button>
  </span>
    </el-dialog>
  </div>
</template>
<script>
  import {handleSGBZ18} from "../../../api/edu/risk";

  export default {
    components: {},
    props: [],
    data() {
      return {
        centerDialogVisible : false,

        formData: {
          number: '',
          sxygx: undefined,
          jcdll: undefined,
          zbll: undefined,
        },
        rules: {
          number: [{
            required: true,
            message: '请输入编号',
            trigger: 'blur'
          }],
          sxygx: [{
            required: true,
            message: '请选择压力计和流量计的上下游关系',
            trigger: 'change'
          }],
          jcdll: [{
            required: true,
            message: '请输入监测点流量（m^3/s）',
            trigger: 'blur'
          }],
          zbll: [{
            required: true,
            message: '请输入周边流量（m^3/s）',
            trigger: 'blur'
          }],
        },
        sxygxOptions: [{
          "label": "流量计的流向与压力计的位置相同",
          "value": 1
        }, {
          "label": "流量计的流向与压力计的位置相反",
          "value": 0
        }],
      }
    },
    computed: {},
    watch: {},
    created() {},
    mounted() {},
    methods: {
      submitForm() {
        handleSGBZ18(this.formData).then(response => {
          console.log(response)
          this.name = response.data.name;
          this.number = response.data.number;
          this.centerDialogVisible = true
        }).catch((error) => {
          console.log(error);
        });
      },
      resetForm() {
        this.$refs['elForm'].resetFields()
      },
    }
  }

</script>
<style>
</style>
